<!-- 名片详情 -->
<template>
	<view class="card-details">
		<TemplateOne ref="detailRef" :data="dataForm" @onShare="openshare" v-if="dataForm.style == 0" />
		<!-- 默认风格 -->
		<TemplateTne :data="dataForm" @onShare="openshare" v-else-if="dataForm.style == 1" />
		<!-- 蓝色风格 -->
		<TemplateThree :data="dataForm" @onShare="openshare" v-else-if="dataForm.style == 2" />
		<!-- 黄色风格 -->
		<TemplateFour :data="dataForm" @onShare="openshare" v-else-if="dataForm.style == 3" />
		<!-- 橙色风格 -->
		<templateFive :data="dataForm" @onShare="openshare" v-else-if="dataForm.style == 4" />
		<!-- 绿色风格 -->
		<templateSix :data="dataForm" @onShare="openshare" v-else-if="dataForm.style == 5" />
		<!-- 棕色风格 -->
		<recom-prod ref="recom_prod" :userId="vuex_user.pk_id"></recom-prod>
		<card-sidebar v-model="showshare" zIndex="1000" :prodInfo="dataForm"></card-sidebar>
	</view>
</template>

<script>
import TemplateOne from '../home-template/template-one.vue';
import TemplateTne from '../home-template/template-two.vue';
import TemplateThree from '../home-template/template-three.vue';
import TemplateFour from '../home-template/template-four.vue';
import templateFive from '../home-template/template-five.vue';
import templateSix from '../home-template/template-six.vue';
import recomProd from '../components/recomProd/index.vue'
import cardSidebar from './card-sidebar';
export default {
	components: {
		TemplateOne,
		TemplateTne,
		TemplateThree,
		TemplateFour,
		templateFive,
		templateSix,
		'recom-prod':recomProd,
		cardSidebar
	},
	data() {
		return {
			showshare: false,
			dataForm: {}
		};
	},
	mounted() {
		this.initPage();
	},
	methods: {
		// 初始化页面
		initPage() {
			let params = {
				// 判断当前card_id 是自己的还是别人的
				pk_id: this.vuex_user.card_id,
				users_id: this.vuex_user.pk_id,
				relation_users_id: this.vuex_user.pk_id || undefined
			};
			this.$resPost('GetCallingCardList', params).then(({ data }) => {
				if (data[0].img) {
					data[0].imgList = data[0].img.split(',');
				}
				this.dataForm = data[0] || {};
				if (this.dataForm.style == '0') {
					this.pageScrollTo();
				}
			});
		},
		openshare() {
			this.showshare = true;
		},
		// 将页面向上滚动215像素
		pageScrollTo() {
			this.$nextTick(function() {
				uni.pageScrollTo({
					scrollTop: 215,
					duration: 0
				});
			});
		},
		$onPageScroll: function(scrollTop) {
			if (!!this.$refs.detailRef) {
				this.$nextTick(() => {
					this.$refs.detailRef.$onPageScroll(scrollTop);
				});
			}
		},
		$onReachBottom() {
			if (!!this.$refs.recom_prod) {
				this.$nextTick(() => {
					this.$refs.recom_prod.$onReachBottom();
				});
			}
		}
	}
};
</script>

<style lang="scss" scoped></style>
